﻿namespace ExamV5.RubricInfo
{
    using ExamV5;
    using System;
    using System.Configuration;
    using System.Data;
    using System.Data.OleDb;
    using System.Data.SqlClient;
    using System.Web;
    using System.Web.UI;
    using System.Web.UI.HtmlControls;
    using System.Web.UI.WebControls;

    public class FrmUploadXLSRubric : Page
    {
        protected Button butClose;
        protected Button butDefault;
        protected CheckBoxList CBLFlag;
        protected DropDownList DDLSubject;
        protected HtmlForm form1;
        protected HtmlHead Head1;
        private HttpCookie httpCookie_0 = null;
        private HttpCookie httpCookie_1 = null;
        private HttpCookie httpCookie_2 = null;
        private HttpCookie httpCookie_3 = null;
        protected Label labRubricError;
        private PublicFun publicFun_0 = new PublicFun();
        protected RadioButtonList RBLIsShare;
        protected HtmlInputFile UPUserData;

        protected void butDefault_Click(object sender, EventArgs e)
        {
            string str = "";
            string fileName = this.UPUserData.PostedFile.FileName;
            if (!(fileName.Trim() != ""))
            {
                base.Response.Write("<script>alert('文件格式不正确！请选择扩展名为xls或xlsx的文件！')</script>");
            }
            else
            {
                try
                {
                    string str19 = fileName.Substring(fileName.LastIndexOf('.'));
                    string str20 = ".XLS.XLSX";
                    if (str20.IndexOf(str19.ToUpper()) < 0)
                    {
                        base.Response.Write("<script>alert('文件格式不正确！请选择扩展名为xls或xlsx的文件')</script>");
                        return;
                    }
                    if (fileName.IndexOf(@"\", 0) > 0)
                    {
                        int num7 = fileName.LastIndexOf(@"\");
                        fileName = fileName.Substring(num7 + 1);
                        fileName = this.httpCookie_0.Value + "Rubricxls" + str19;
                    }
                    this.UPUserData.PostedFile.SaveAs(base.Server.MapPath("../") + @"\PublicFile\" + fileName);
                }
                catch
                {
                    base.Response.Write(@"<script>alert('导入数据失败！\n\n请将PublicFile目录设置为Everyone用户可修改权限！')</script>");
                    return;
                }
                string str18 = base.Server.MapPath("../") + @"\PublicFile\" + fileName;
                string str14 = "";
                if (fileName.ToUpper().IndexOf(".XLSX") != -1)
                {
                    str14 = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" + str18 + ";Extended Properties=\"Excel 12.0 Xml;HDR=YES;IMEX=1\";";
                }
                else
                {
                    str14 = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + str18 + ";Extended Properties='Excel 8.0;HDR=YES;IMEX=1'";
                }
                if (this.publicFun_0.GetValues("select ParmValue from SysParmInfo where ParmMemo='RubricLoop'", "ParmValue").Trim().Trim() == "Y")
                {
                    string str16 = this.method_0(str14);
                    if (str16 != "")
                    {
                        base.Response.Write("<script>alert('" + str16 + "试题在题库中已经存在，请仔细核实！')</script>");
                        this.labRubricError.Text = str16 + "试题在题库中已经存在，请仔细核实！";
                        return;
                    }
                }
                OleDbConnection connection = new OleDbConnection(str14);
                connection.Open();
                string str3 = "";
                string str11 = "";
                string str10 = "N";
                string str5 = "A";
                string str6 = "";
                string str7 = "";
                string str8 = "";
                string str9 = "";
                string str12 = "";
                int num2 = 0;
                int length = 0;
                int maxValue = 0x2710;
                SqlConnection connection2 = new SqlConnection(ConfigurationManager.ConnectionStrings["Conn"].ConnectionString);
                connection2.Open();
                Random random = new Random();
                SqlTransaction transaction = connection2.BeginTransaction();
                SqlCommand command2 = null;
                try
                {
                    OleDbCommand command = new OleDbCommand("select * from [sheet1$]", connection);
                    OleDbDataReader reader = command.ExecuteReader(CommandBehavior.CloseConnection);
                    while (reader.Read())
                    {
                        if (!(reader[0].ToString().Replace(" ", "").Replace("　", "") != "") || !(reader[1].ToString().Trim().Replace(" ", "").Replace("　", "") != ""))
                        {
                            continue;
                        }
                        if (reader[9].ToString() == null)
                        {
                            str12 = "";
                        }
                        else
                        {
                            str12 = reader[9].ToString().Trim();
                        }
                        if (reader[10].ToString() != null)
                        {
                            switch (reader[10].ToString().Replace("　", "").Replace("&nbsp;", " ").Replace("<BR />", "").Replace("<br>", "").Replace("<BR>", ""))
                            {
                                case "难":
                                    str7 = "A";
                                    goto Label_0444;

                                case "较难":
                                    str7 = "B";
                                    goto Label_0444;

                                case "中等":
                                    str7 = "C";
                                    goto Label_0444;

                                case "较易":
                                    str7 = "D";
                                    goto Label_0444;

                                case "容易":
                                    str7 = "E";
                                    goto Label_0444;
                            }
                            str7 = "C";
                        }
                        else
                        {
                            str7 = "C";
                        }
                    Label_0444:
                        maxValue++;
                        str11 = random.Next(maxValue).ToString();
                        str6 = reader[1].ToString().Trim().Replace("<br />", "<br>").Replace("<BR />", "<br>").Replace("\r\n", "");
                        switch (reader[0].ToString().Trim().Replace(" ", "").Replace("　", "").Replace("<br />", "<br>").Replace("<BR />", "<br>").Replace("\r\n", "").Replace("题", ""))
                        {
                            case "单选":
                                str3 = "A";
                                if (reader[2].ToString() != null)
                                {
                                    break;
                                }
                                str8 = "A";
                                goto Label_060F;

                            case "多选":
                                str3 = "B";
                                if (reader[2].ToString() != null)
                                {
                                    goto Label_0B5E;
                                }
                                str8 = "A";
                                goto Label_0B7C;

                            case "判断":
                                str3 = "C";
                                str8 = "";
                                if (reader[2].ToString() != null)
                                {
                                    goto Label_118B;
                                }
                                str9 = "Y";
                                goto Label_1294;

                            case "填空":
                                str3 = "D";
                                str8 = "";
                                length = str6.Replace("___", "┌").Split(new char[] { '┌' }).Length;
                                if (reader[2].ToString() == null)
                                {
                                    goto Label_15DC;
                                }
                                str9 = reader[2].ToString().Trim().Replace("＃", "#").Replace(" ", "").Replace("　", "").Replace("<br />", "<br>").Replace("<BR />", "<br>").Replace("\r\n", "").Replace("&nbsp;", " ").Replace("<BR />", "").Replace("<BR>", "");
                                goto Label_15E3;

                            case "简答":
                                str3 = "E";
                                str8 = "";
                                if (reader[2].ToString() != null)
                                {
                                    goto Label_18F7;
                                }
                                str9 = "";
                                goto Label_1974;

                            case "论述":
                                str3 = "G";
                                str8 = "";
                                if (reader[2].ToString() == null)
                                {
                                    goto Label_1C6E;
                                }
                                str9 = reader[2].ToString().Trim().Replace("＃", "#").Replace("<br />", "<br>").Replace("<BR />", "<br>").Replace("\r\n", "").Replace("&nbsp;", " ").Replace("<BR />", "").Replace("<BR>", "");
                                goto Label_1C75;

                            case "分析":
                                str3 = "H";
                                str8 = "";
                                if (reader[2].ToString() != null)
                                {
                                    goto Label_1EF9;
                                }
                                str9 = "";
                                goto Label_1F76;

                            case "作文":
                                str3 = "F";
                                str8 = "";
                                if (reader[2].ToString() != null)
                                {
                                    goto Label_21FA;
                                }
                                str9 = "";
                                goto Label_2277;

                            default:
                                goto Label_24CF;
                        }
                        str8 = reader[2].ToString().Replace("#", "＃");
                    Label_060F:
                        if (reader[3].ToString() == null)
                        {
                            str8 = str8 + "#B";
                        }
                        else
                        {
                            str8 = str8 + "#" + reader[3].ToString().Replace("#", "＃");
                        }
                        if (reader[4].ToString() != null)
                        {
                            str8 = str8 + "#" + reader[4].ToString().Replace("#", "＃");
                        }
                        else
                        {
                            str8 = str8 + "#C";
                        }
                        if (reader[5].ToString() != null)
                        {
                            str8 = str8 + "#" + reader[5].ToString().Replace("#", "＃");
                        }
                        else
                        {
                            str8 = str8 + "#D";
                        }
                        if (reader[6].ToString() != null)
                        {
                            str8 = str8 + "#" + reader[6].ToString().Replace("#", "＃");
                        }
                        else
                        {
                            str8 = str8 + "#E";
                        }
                        if (reader[7].ToString() != null)
                        {
                            str8 = str8 + "#" + reader[7].ToString().Replace("#", "＃");
                        }
                        else
                        {
                            str8 = str8 + "#F";
                        }
                        length = str8.Split(new char[] { '#' }).Length;
                        int num3 = 0;
                        while (num3 < (6 - length))
                        {
                            str8 = str8 + "#";
                            num3++;
                        }
                        if (reader[8].ToString() == null)
                        {
                            str9 = "A";
                        }
                        else
                        {
                            str9 = reader[8].ToString().Trim().Replace("　", "").Replace(" ", "").Replace("&NBSP;", "").Replace("&nbsp;", "").Replace("<br />", "<br>").Replace("<BR />", "<br>").Replace("\r\n", "").Replace("<BR />", "").Replace("<BR>", "").Replace("Ａ", "A").Replace("Ｂ", "B").Replace("Ｃ", "C").Replace("Ｄ", "D").Replace("Ｅ", "E").Replace("Ｆ", "F").ToUpper();
                        }
                        num2 = 0;
                        while (num2 < this.CBLFlag.Items.Count)
                        {
                            if (this.CBLFlag.Items[num2].Selected)
                            {
                                str5 = this.CBLFlag.Items[num2].Value;
                                str = "Insert into RubricInfo(RubricType,SubjectID,RubricTitle,Difficulty,OptionAnswer,OKAnswer,IsShare,ISCheck,Flag,IsUse,RndNumber,CreatNumberNO,OKMemo) Values(";
                                command2 = new SqlCommand(str + "@RubricType,@SubjectID,@RubricTitle,@Difficulty,@OptionAnswer,@OKAnswer,@IsShare,@ISCheck,@Flag,@IsUse,@RndNumber,@CreatNumberNO,@OKMemo)", connection2) {
                                    CommandTimeout = 0,
                                    Transaction = transaction
                                };
                                command2.Parameters.Add("@RubricType", SqlDbType.Char, 1).Value = str3;
                                command2.Parameters.Add("@SubjectID", SqlDbType.Int).Value = this.DDLSubject.SelectedItem.Value;
                                command2.Parameters.Add("@RubricTitle", SqlDbType.Text).Value = str6;
                                command2.Parameters.Add("@Difficulty", SqlDbType.Char, 1).Value = str7;
                                command2.Parameters.Add("@OptionAnswer", SqlDbType.Text).Value = str8.Replace("<BR>", "").Replace("&nbsp;", " ").Replace("<br />", "").Replace("<br>", "");
                                command2.Parameters.Add("@OKAnswer", SqlDbType.Text).Value = str9;
                                command2.Parameters.Add("@IsShare", SqlDbType.Char, 1).Value = this.RBLIsShare.SelectedItem.Value;
                                command2.Parameters.Add("@ISCheck", SqlDbType.Char, 1).Value = "N";
                                command2.Parameters.Add("@IsUse", SqlDbType.Char, 1).Value = str10;
                                command2.Parameters.Add("@RndNumber", SqlDbType.Int).Value = str11;
                                command2.Parameters.Add("@CreatNumberNO", SqlDbType.VarChar, 20).Value = this.httpCookie_0.Value;
                                command2.Parameters.Add("@OKMemo", SqlDbType.VarChar, 0x1388).Value = str12;
                                command2.Parameters.Add("@Flag", SqlDbType.Char, 1).Value = str5;
                                command2.ExecuteNonQuery();
                                command2.Dispose();
                            }
                            num2++;
                        }
                        continue;
                    Label_0B5E:
                        str8 = reader[2].ToString().Replace("#", "＃");
                    Label_0B7C:
                        if (reader[3].ToString() == null)
                        {
                            str8 = str8 + "#B";
                        }
                        else
                        {
                            str8 = str8 + "#" + reader[3].ToString().Replace("#", "＃");
                        }
                        if (reader[4].ToString() == null)
                        {
                            str8 = str8 + "#C";
                        }
                        else
                        {
                            str8 = str8 + "#" + reader[4].ToString().Replace("#", "＃");
                        }
                        if (reader[5].ToString() != null)
                        {
                            str8 = str8 + "#" + reader[5].ToString().Replace("#", "＃");
                        }
                        else
                        {
                            str8 = str8 + "#D";
                        }
                        if (reader[6].ToString() == null)
                        {
                            str8 = str8 + "#E";
                        }
                        else
                        {
                            str8 = str8 + "#" + reader[6].ToString().Replace("#", "＃");
                        }
                        if (reader[7].ToString() == null)
                        {
                            str8 = str8 + "#F";
                        }
                        else
                        {
                            str8 = str8 + "#" + reader[7].ToString().Replace("#", "＃");
                        }
                        length = str8.Split(new char[] { '#' }).Length;
                        num3 = 0;
                        while (num3 < (6 - length))
                        {
                            str8 = str8 + "#";
                            num3++;
                        }
                        if (reader[8].ToString() != null)
                        {
                            if (reader[8].ToString().IndexOf("#") == -1)
                            {
                                str9 = "";
                                for (int i = 0; i < reader[8].ToString().Trim().Length; i++)
                                {
                                    string str13 = reader[8].ToString().Trim().Substring(i, 1);
                                    str9 = str9 + str13 + "#";
                                }
                                if (str9.Length > 1)
                                {
                                    str9 = str9.Substring(0, str9.Length - 1);
                                }
                            }
                            else
                            {
                                str9 = reader[8].ToString().Trim().Replace("＃", "#").Replace("　", "").Replace(" ", "").Replace("&NBSP;", "").Replace("&nbsp;", "").Replace("<br />", "<br>").Replace("<BR />", "<br>").Replace("\r\n", "").Replace("<BR />", "").Replace("<BR>", "").Replace("Ａ", "A").Replace("Ｂ", "B").Replace("Ｃ", "C").Replace("Ｄ", "D").Replace("Ｅ", "E").Replace("Ｆ", "F").ToUpper();
                            }
                        }
                        else
                        {
                            str9 = "A#B#C#D";
                        }
                        num2 = 0;
                        while (num2 < this.CBLFlag.Items.Count)
                        {
                            if (this.CBLFlag.Items[num2].Selected)
                            {
                                str5 = this.CBLFlag.Items[num2].Value;
                                str = "Insert into RubricInfo(RubricType,SubjectID,RubricTitle,Difficulty,OptionAnswer,OKAnswer,IsShare,ISCheck,Flag,IsUse,RndNumber,CreatNumberNO,OKMemo) Values(";
                                command2 = new SqlCommand(str + "@RubricType,@SubjectID,@RubricTitle,@Difficulty,@OptionAnswer,@OKAnswer,@IsShare,@ISCheck,@Flag,@IsUse,@RndNumber,@CreatNumberNO,@OKMemo)", connection2) {
                                    CommandTimeout = 0,
                                    Transaction = transaction
                                };
                                command2.Parameters.Add("@RubricType", SqlDbType.Char, 1).Value = str3;
                                command2.Parameters.Add("@SubjectID", SqlDbType.Int).Value = this.DDLSubject.SelectedItem.Value;
                                command2.Parameters.Add("@RubricTitle", SqlDbType.Text).Value = str6;
                                command2.Parameters.Add("@Difficulty", SqlDbType.Char, 1).Value = str7;
                                command2.Parameters.Add("@OptionAnswer", SqlDbType.Text).Value = str8.Replace("<BR>", "").Replace("&nbsp;", " ").Replace("<br />", "").Replace("<br>", "");
                                command2.Parameters.Add("@OKAnswer", SqlDbType.Text).Value = str9;
                                command2.Parameters.Add("@IsShare", SqlDbType.Char, 1).Value = this.RBLIsShare.SelectedItem.Value;
                                command2.Parameters.Add("@ISCheck", SqlDbType.Char, 1).Value = "N";
                                command2.Parameters.Add("@IsUse", SqlDbType.Char, 1).Value = str10;
                                command2.Parameters.Add("@RndNumber", SqlDbType.Int).Value = str11;
                                command2.Parameters.Add("@CreatNumberNO", SqlDbType.VarChar, 20).Value = this.httpCookie_0.Value;
                                command2.Parameters.Add("@OKMemo", SqlDbType.VarChar, 0x1388).Value = str12;
                                command2.Parameters.Add("@Flag", SqlDbType.Char, 1).Value = str5;
                                command2.ExecuteNonQuery();
                                command2.Dispose();
                            }
                            num2++;
                        }
                        continue;
                    Label_118B:
                        str9 = reader[2].ToString().Trim().Replace(" ", "").Replace("　", "").Replace("<br />", "<br>").Replace("<BR />", "<br>").Replace("\r\n", "").Replace("&nbsp;", " ").Replace("<BR />", "").Replace("<BR>", "").Replace("Ｙ", "Y").Replace("Ｎ", "N").Replace("错误", "N").Replace("错", "N").Replace("\x00d7", "N").Replace("正确", "Y").Replace("对", "Y").Replace("√", "Y").ToUpper();
                    Label_1294:
                        num2 = 0;
                        while (num2 < this.CBLFlag.Items.Count)
                        {
                            if (this.CBLFlag.Items[num2].Selected)
                            {
                                str5 = this.CBLFlag.Items[num2].Value;
                                str = "Insert into RubricInfo(RubricType,SubjectID,RubricTitle,Difficulty,OptionAnswer,OKAnswer,IsShare,ISCheck,Flag,IsUse,RndNumber,CreatNumberNO,OKMemo) Values(";
                                command2 = new SqlCommand(str + "@RubricType,@SubjectID,@RubricTitle,@Difficulty,@OptionAnswer,@OKAnswer,@IsShare,@ISCheck,@Flag,@IsUse,@RndNumber,@CreatNumberNO,@OKMemo)", connection2) {
                                    CommandTimeout = 0,
                                    Transaction = transaction
                                };
                                command2.Parameters.Add("@RubricType", SqlDbType.Char, 1).Value = str3;
                                command2.Parameters.Add("@SubjectID", SqlDbType.Int).Value = this.DDLSubject.SelectedItem.Value;
                                command2.Parameters.Add("@RubricTitle", SqlDbType.Text).Value = str6;
                                command2.Parameters.Add("@Difficulty", SqlDbType.Char, 1).Value = str7;
                                command2.Parameters.Add("@OptionAnswer", SqlDbType.Text).Value = str8.Replace("<BR>", "").Replace("&nbsp;", " ").Replace("<br />", "").Replace("<br>", "");
                                command2.Parameters.Add("@OKAnswer", SqlDbType.Text).Value = str9;
                                command2.Parameters.Add("@IsShare", SqlDbType.Char, 1).Value = this.RBLIsShare.SelectedItem.Value;
                                command2.Parameters.Add("@ISCheck", SqlDbType.Char, 1).Value = "N";
                                command2.Parameters.Add("@IsUse", SqlDbType.Char, 1).Value = str10;
                                command2.Parameters.Add("@RndNumber", SqlDbType.Int).Value = str11;
                                command2.Parameters.Add("@CreatNumberNO", SqlDbType.VarChar, 20).Value = this.httpCookie_0.Value;
                                command2.Parameters.Add("@OKMemo", SqlDbType.VarChar, 0x1388).Value = str12;
                                command2.Parameters.Add("@Flag", SqlDbType.Char, 1).Value = str5;
                                command2.ExecuteNonQuery();
                                command2.Dispose();
                            }
                            num2++;
                        }
                        continue;
                    Label_15DC:
                        str9 = "";
                    Label_15E3:
                        if (str9.Trim() != "")
                        {
                            length = str9.Split(new char[] { '#' }).Length;
                            for (num3 = 0; num3 < (6 - length); num3++)
                            {
                                str9 = str9 + "#";
                            }
                            if (str6.Replace("___", "┌").Split(new char[] { '┌' }).Length == (length + 1))
                            {
                                num2 = 0;
                                while (num2 < this.CBLFlag.Items.Count)
                                {
                                    if (this.CBLFlag.Items[num2].Selected)
                                    {
                                        str5 = this.CBLFlag.Items[num2].Value;
                                        str = "Insert into RubricInfo(RubricType,SubjectID,RubricTitle,Difficulty,OptionAnswer,OKAnswer,IsShare,ISCheck,Flag,IsUse,RndNumber,CreatNumberNO,OKMemo) Values(";
                                        command2 = new SqlCommand(str + "@RubricType,@SubjectID,@RubricTitle,@Difficulty,@OptionAnswer,@OKAnswer,@IsShare,@ISCheck,@Flag,@IsUse,@RndNumber,@CreatNumberNO,@OKMemo)", connection2) {
                                            CommandTimeout = 0,
                                            Transaction = transaction
                                        };
                                        command2.Parameters.Add("@RubricType", SqlDbType.Char, 1).Value = str3;
                                        command2.Parameters.Add("@SubjectID", SqlDbType.Int).Value = this.DDLSubject.SelectedItem.Value;
                                        command2.Parameters.Add("@RubricTitle", SqlDbType.Text).Value = str6;
                                        command2.Parameters.Add("@Difficulty", SqlDbType.Char, 1).Value = str7;
                                        command2.Parameters.Add("@OptionAnswer", SqlDbType.Text).Value = str8.Replace("<BR>", "").Replace("&nbsp;", " ").Replace("<br />", "").Replace("<br>", "");
                                        command2.Parameters.Add("@OKAnswer", SqlDbType.Text).Value = str9;
                                        command2.Parameters.Add("@IsShare", SqlDbType.Char, 1).Value = this.RBLIsShare.SelectedItem.Value;
                                        command2.Parameters.Add("@ISCheck", SqlDbType.Char, 1).Value = "N";
                                        command2.Parameters.Add("@IsUse", SqlDbType.Char, 1).Value = str10;
                                        command2.Parameters.Add("@RndNumber", SqlDbType.Int).Value = str11;
                                        command2.Parameters.Add("@CreatNumberNO", SqlDbType.VarChar, 20).Value = this.httpCookie_0.Value;
                                        command2.Parameters.Add("@OKMemo", SqlDbType.VarChar, 0x1388).Value = str12;
                                        command2.Parameters.Add("@Flag", SqlDbType.Char, 1).Value = str5;
                                        command2.ExecuteNonQuery();
                                        command2.Dispose();
                                    }
                                    num2++;
                                }
                            }
                        }
                        continue;
                    Label_18F7:
                        str9 = reader[2].ToString().Trim().Replace("＃", "#").Replace("<br />", "<br>").Replace("<BR />", "<br>").Replace("\r\n", "").Replace("&nbsp;", " ").Replace("<BR />", "").Replace("<BR>", "");
                    Label_1974:
                        num2 = 0;
                        while (num2 < this.CBLFlag.Items.Count)
                        {
                            if (this.CBLFlag.Items[num2].Selected)
                            {
                                str5 = this.CBLFlag.Items[num2].Value;
                                str = "Insert into RubricInfo(RubricType,SubjectID,RubricTitle,Difficulty,OptionAnswer,OKAnswer,IsShare,ISCheck,Flag,IsUse,RndNumber,CreatNumberNO,OKMemo) Values(";
                                command2 = new SqlCommand(str + "@RubricType,@SubjectID,@RubricTitle,@Difficulty,@OptionAnswer,@OKAnswer,@IsShare,@ISCheck,@Flag,@IsUse,@RndNumber,@CreatNumberNO,@OKMemo)", connection2) {
                                    CommandTimeout = 0,
                                    Transaction = transaction
                                };
                                command2.Parameters.Add("@RubricType", SqlDbType.Char, 1).Value = str3;
                                command2.Parameters.Add("@SubjectID", SqlDbType.Int).Value = this.DDLSubject.SelectedItem.Value;
                                command2.Parameters.Add("@RubricTitle", SqlDbType.Text).Value = str6;
                                command2.Parameters.Add("@Difficulty", SqlDbType.Char, 1).Value = str7;
                                command2.Parameters.Add("@OptionAnswer", SqlDbType.Text).Value = str8.Replace("<BR>", "").Replace("&nbsp;", " ").Replace("<br />", "").Replace("<br>", "");
                                command2.Parameters.Add("@OKAnswer", SqlDbType.Text).Value = str9;
                                command2.Parameters.Add("@IsShare", SqlDbType.Char, 1).Value = this.RBLIsShare.SelectedItem.Value;
                                command2.Parameters.Add("@ISCheck", SqlDbType.Char, 1).Value = "N";
                                command2.Parameters.Add("@IsUse", SqlDbType.Char, 1).Value = str10;
                                command2.Parameters.Add("@RndNumber", SqlDbType.Int).Value = str11;
                                command2.Parameters.Add("@CreatNumberNO", SqlDbType.VarChar, 20).Value = this.httpCookie_0.Value;
                                command2.Parameters.Add("@OKMemo", SqlDbType.VarChar, 0x1388).Value = str12;
                                command2.Parameters.Add("@Flag", SqlDbType.Char, 1).Value = str5;
                                command2.ExecuteNonQuery();
                                command2.Dispose();
                            }
                            num2++;
                        }
                        continue;
                    Label_1C6E:
                        str9 = "";
                    Label_1C75:
                        num2 = 0;
                        while (num2 < this.CBLFlag.Items.Count)
                        {
                            if (this.CBLFlag.Items[num2].Selected)
                            {
                                str5 = this.CBLFlag.Items[num2].Value;
                                str = "Insert into RubricInfo(RubricType,SubjectID,RubricTitle,Difficulty,OptionAnswer,OKAnswer,IsShare,ISCheck,Flag,IsUse,RndNumber,CreatNumberNO,OKMemo) Values(";
                                command2 = new SqlCommand(str + "@RubricType,@SubjectID,@RubricTitle,@Difficulty,@OptionAnswer,@OKAnswer,@IsShare,@ISCheck,@Flag,@IsUse,@RndNumber,@CreatNumberNO,@OKMemo)", connection2) {
                                    CommandTimeout = 0,
                                    Transaction = transaction
                                };
                                command2.Parameters.Add("@RubricType", SqlDbType.Char, 1).Value = str3;
                                command2.Parameters.Add("@SubjectID", SqlDbType.Int).Value = this.DDLSubject.SelectedItem.Value;
                                command2.Parameters.Add("@RubricTitle", SqlDbType.Text).Value = str6;
                                command2.Parameters.Add("@Difficulty", SqlDbType.Char, 1).Value = str7;
                                command2.Parameters.Add("@OptionAnswer", SqlDbType.Text).Value = str8.Replace("<BR>", "").Replace("&nbsp;", " ").Replace("<br />", "").Replace("<br>", "");
                                command2.Parameters.Add("@OKAnswer", SqlDbType.Text).Value = str9;
                                command2.Parameters.Add("@IsShare", SqlDbType.Char, 1).Value = this.RBLIsShare.SelectedItem.Value;
                                command2.Parameters.Add("@ISCheck", SqlDbType.Char, 1).Value = "N";
                                command2.Parameters.Add("@IsUse", SqlDbType.Char, 1).Value = str10;
                                command2.Parameters.Add("@RndNumber", SqlDbType.Int).Value = str11;
                                command2.Parameters.Add("@CreatNumberNO", SqlDbType.VarChar, 20).Value = this.httpCookie_0.Value;
                                command2.Parameters.Add("@OKMemo", SqlDbType.VarChar, 0x1388).Value = str12;
                                command2.Parameters.Add("@Flag", SqlDbType.Char, 1).Value = str5;
                                command2.ExecuteNonQuery();
                                command2.Dispose();
                            }
                            num2++;
                        }
                        continue;
                    Label_1EF9:
                        str9 = reader[2].ToString().Trim().Replace("＃", "#").Replace("<br />", "<br>").Replace("<BR />", "<br>").Replace("\r\n", "").Replace("&nbsp;", " ").Replace("<BR />", "").Replace("<BR>", "");
                    Label_1F76:
                        num2 = 0;
                        while (num2 < this.CBLFlag.Items.Count)
                        {
                            if (this.CBLFlag.Items[num2].Selected)
                            {
                                str5 = this.CBLFlag.Items[num2].Value;
                                str = "Insert into RubricInfo(RubricType,SubjectID,RubricTitle,Difficulty,OptionAnswer,OKAnswer,IsShare,ISCheck,Flag,IsUse,RndNumber,CreatNumberNO,OKMemo) Values(";
                                command2 = new SqlCommand(str + "@RubricType,@SubjectID,@RubricTitle,@Difficulty,@OptionAnswer,@OKAnswer,@IsShare,@ISCheck,@Flag,@IsUse,@RndNumber,@CreatNumberNO,@OKMemo)", connection2) {
                                    CommandTimeout = 0,
                                    Transaction = transaction
                                };
                                command2.Parameters.Add("@RubricType", SqlDbType.Char, 1).Value = str3;
                                command2.Parameters.Add("@SubjectID", SqlDbType.Int).Value = this.DDLSubject.SelectedItem.Value;
                                command2.Parameters.Add("@RubricTitle", SqlDbType.Text).Value = str6;
                                command2.Parameters.Add("@Difficulty", SqlDbType.Char, 1).Value = str7;
                                command2.Parameters.Add("@OptionAnswer", SqlDbType.Text).Value = str8.Replace("<BR>", "").Replace("&nbsp;", " ").Replace("<br />", "").Replace("<br>", "");
                                command2.Parameters.Add("@OKAnswer", SqlDbType.Text).Value = str9;
                                command2.Parameters.Add("@IsShare", SqlDbType.Char, 1).Value = this.RBLIsShare.SelectedItem.Value;
                                command2.Parameters.Add("@ISCheck", SqlDbType.Char, 1).Value = "N";
                                command2.Parameters.Add("@IsUse", SqlDbType.Char, 1).Value = str10;
                                command2.Parameters.Add("@RndNumber", SqlDbType.Int).Value = str11;
                                command2.Parameters.Add("@CreatNumberNO", SqlDbType.VarChar, 20).Value = this.httpCookie_0.Value;
                                command2.Parameters.Add("@OKMemo", SqlDbType.VarChar, 0x1388).Value = str12;
                                command2.Parameters.Add("@Flag", SqlDbType.Char, 1).Value = str5;
                                command2.ExecuteNonQuery();
                                command2.Dispose();
                            }
                            num2++;
                        }
                        continue;
                    Label_21FA:
                        str9 = reader[2].ToString().Trim().Replace("＃", "#").Replace("<br />", "<br>").Replace("<BR />", "<br>").Replace("\r\n", "").Replace("&nbsp;", " ").Replace("<BR />", "").Replace("<BR>", "");
                    Label_2277:
                        num2 = 0;
                        while (num2 < this.CBLFlag.Items.Count)
                        {
                            if (this.CBLFlag.Items[num2].Selected)
                            {
                                str5 = this.CBLFlag.Items[num2].Value;
                                str = "Insert into RubricInfo(RubricType,SubjectID,RubricTitle,Difficulty,OptionAnswer,OKAnswer,IsShare,ISCheck,Flag,IsUse,RndNumber,CreatNumberNO,OKMemo) Values(";
                                command2 = new SqlCommand(str + "@RubricType,@SubjectID,@RubricTitle,@Difficulty,@OptionAnswer,@OKAnswer,@IsShare,@ISCheck,@Flag,@IsUse,@RndNumber,@CreatNumberNO,@OKMemo)", connection2) {
                                    CommandTimeout = 0,
                                    Transaction = transaction
                                };
                                command2.Parameters.Add("@RubricType", SqlDbType.Char, 1).Value = str3;
                                command2.Parameters.Add("@SubjectID", SqlDbType.Int).Value = this.DDLSubject.SelectedItem.Value;
                                command2.Parameters.Add("@RubricTitle", SqlDbType.Text).Value = str6;
                                command2.Parameters.Add("@Difficulty", SqlDbType.Char, 1).Value = str7;
                                command2.Parameters.Add("@OptionAnswer", SqlDbType.Text).Value = str8.Replace("<BR>", "").Replace("&nbsp;", " ").Replace("<br />", "").Replace("<br>", "");
                                command2.Parameters.Add("@OKAnswer", SqlDbType.Text).Value = str9;
                                command2.Parameters.Add("@IsShare", SqlDbType.Char, 1).Value = this.RBLIsShare.SelectedItem.Value;
                                command2.Parameters.Add("@ISCheck", SqlDbType.Char, 1).Value = "N";
                                command2.Parameters.Add("@IsUse", SqlDbType.Char, 1).Value = str10;
                                command2.Parameters.Add("@RndNumber", SqlDbType.Int).Value = str11;
                                command2.Parameters.Add("@CreatNumberNO", SqlDbType.VarChar, 20).Value = this.httpCookie_0.Value;
                                command2.Parameters.Add("@OKMemo", SqlDbType.VarChar, 0x1388).Value = str12;
                                command2.Parameters.Add("@Flag", SqlDbType.Char, 1).Value = str5;
                                command2.ExecuteNonQuery();
                                command2.Dispose();
                            }
                            num2++;
                        }
                        continue;
                    Label_24CF:
                        str3 = "";
                    }
                    reader.Close();
                    command.Dispose();
                    connection.Close();
                    connection.Dispose();
                    transaction.Commit();
                    base.Response.Write("<script>alert('批量导入试题信息操作成功！');window.opener.location.reload();window.close();</script>");
                }
                catch
                {
                    transaction.Rollback();
                    base.Response.Write("<script>alert('批量导入试题信息操作出错！请检查文件格式是否正确！" + str6 + "')</script>");
                }
                finally
                {
                    connection2.Close();
                    connection2.Dispose();
                    connection.Close();
                    connection.Dispose();
                }
            }
        }

        private string method_0(string string_0)
        {
            OleDbConnection connection = new OleDbConnection(string_0);
            connection.Open();
            string str = "";
            for (int i = 0; i < this.CBLFlag.Items.Count; i++)
            {
                if (this.CBLFlag.Items[i].Selected)
                {
                    if (str.Trim() == "")
                    {
                        str = str + "and (Flag='" + this.CBLFlag.Items[i].Value + "'";
                    }
                    else
                    {
                        str = str + " or Flag='" + this.CBLFlag.Items[i].Value + "'";
                    }
                }
            }
            if (str != "")
            {
                str = str + ")";
            }
            string str2 = "";
            OleDbCommand command = new OleDbCommand("select * from [sheet1$]", connection);
            OleDbDataReader reader = command.ExecuteReader(CommandBehavior.CloseConnection);
            while (reader.Read())
            {
                if (reader[1].ToString().Trim().Replace(" ", "").Replace("　", "") != "")
                {
                    string str4 = reader[1].ToString().Trim().Replace("<br />", "<br>").Replace("<BR />", "<br>").Replace("\r\n", "").Replace("'", "‘").Replace(";", "；").Replace("(", "（").Replace(")", "）");
                    if (this.publicFun_0.GetValues("select ID from RubricInfo where RubricTitle like '%" + str4 + "%'" + str, "ID") != "")
                    {
                        str2 = str4;
                        break;
                    }
                }
            }
            command.Dispose();
            reader.Close();
            reader.Dispose();
            connection.Close();
            connection.Dispose();
            return str2;
        }

        protected void Page_Load(object sender, EventArgs e)
        {
            this.httpCookie_0 = new HttpCookie("ExamUserCode");
            this.httpCookie_0 = base.Request.Cookies["ExamUserCode"];
            this.httpCookie_1 = new HttpCookie("ExamUserName");
            this.httpCookie_1 = base.Request.Cookies["ExamUserName"];
            this.httpCookie_2 = new HttpCookie("ExamUserLevel");
            this.httpCookie_2 = base.Request.Cookies["ExamUserLevel"];
            this.httpCookie_3 = new HttpCookie("ExamDeptID");
            this.httpCookie_3 = base.Request.Cookies["ExamDeptID"];
            if ((this.httpCookie_0 != null) ? !(this.httpCookie_0.Value == "") : false)
            {
                base.Response.Cache.SetCacheability(HttpCacheability.NoCache);
                base.Response.Cache.SetNoStore();
                this.httpCookie_0.Value = this.publicFun_0.CheckString(base.Server.UrlDecode(this.httpCookie_0.Value));
                this.httpCookie_1.Value = this.publicFun_0.CheckString(base.Server.UrlDecode(this.httpCookie_1.Value));
                this.httpCookie_2.Value = this.publicFun_0.CheckString(base.Server.UrlDecode(this.httpCookie_2.Value));
                this.httpCookie_3.Value = this.publicFun_0.CheckString(base.Server.UrlDecode(this.httpCookie_3.Value));
                base.Title = ConfigurationManager.ConnectionStrings["ProTitle"].ConnectionString + "---批量导入excel格式试题";
                if (!base.IsPostBack)
                {
                    if (this.publicFun_0.ReturnPaperData() == "Yes")
                    {
                        SqlConnection connection = new SqlConnection(ConfigurationManager.ConnectionStrings["Conn"].ConnectionString);
                        connection.Open();
                        SqlCommand command = new SqlCommand("select AddRubric,ManagRubric from UserPower where UserCode='" + this.httpCookie_0.Value + "'", connection);
                        SqlDataReader reader = command.ExecuteReader(CommandBehavior.CloseConnection);
                        if (reader.Read())
                        {
                            this.ViewState["AddPower"] = reader["AddRubric"].ToString();
                            this.ViewState["ManagPower"] = reader["ManagRubric"].ToString();
                        }
                        reader.Close();
                        command.Dispose();
                        connection.Close();
                        connection.Dispose();
                        if (!(this.ViewState["AddPower"].ToString() != "Y") || !(this.ViewState["ManagPower"].ToString() != "Y"))
                        {
                            this.publicFun_0.LoadSubjectInfo(this.DDLSubject, this.httpCookie_0.Value, this.ViewState["ManagPower"].ToString(), "E", this.httpCookie_3.Value);
                            this.DDLSubject.Items.Insert(0, new ListItem("--请选择所属科目信息--", "0"));
                        }
                        else
                        {
                            base.Response.Write("<script>alert('添加或管理题库权限未开放！')</script>");
                            this.butDefault.Visible = false;
                        }
                    }
                    else
                    {
                        base.Response.Write("<script>alert('此版本暂未授权,请拔打(0)13870606104手机号进行授权！')</script>");
                    }
                }
            }
            else
            {
                base.Response.Write("<script language=javascript>top.location.href='../Index.htm';self.close();</script>");
            }
        }
    }
}

